import {
    http
} from '@/utils/request'

// 上次学习
export const fetchMyLastCurr = async (data) => {
    let res = await http.post({
        url: '/read/getmylastcurr',
        data
    })
    return res
}
// 新版阅读首页
export const fetchNewMyLastCurr = async (data) => {
    let res = await http.post({
        url: '/NewRead/index',
        data
    })
    return res
}

// 我的课程 
export const fetchMyCurr = async (data) => {
    let res = await http.post({
        url: '/read/mycurriculum',
        data
    })
    return res
}
export const fetchNewMyCurr = async (data) => {
    let res = await http.post({
        url: '/NewRead/getpackagelist',
        data
    })
    return res
}

// 首页进度
export const fetchReadStatics = async (data) => {
    let res = await http.post({
        url: '/read/readstatics',
        data
    })
    return res
}

// 获取关卡
export const fetchCurriculum = async (data) => {
    let res = await http.post({
        url: '/read/curriculum',
        data
    })
    return res
}// 获取关卡
export const fetchNewCurriculum = async (data) => {
    let res = await http.post({
        url: '/NewRead/lists',
        data
    })
    return res
}
// 是否检测过
export const isChecked = async (data) => {
    let res = await http.post({
        url: '/exam/checkexam',
        data
    })
    return res
}

// 获取文章拆词
export const fetchSplitWrod = async (data) => {
    let res = await http.post({
        url: '/read/splitwords',
        data
    })
    return res
}

// 单词打印
export const wordPrint = async (data) => {
    let res = await http.post({
        url: '/word/prints',
        data
    })
    return res
}

// 一眼会
export const readUpword = async (data) => {
    let res = await http.post({
        url: '/read/upwords',
        data
    })
    return res
}


// 获取具体文章内容
// question_id
export const fetchReadQuestion = async (data) => {
    let res = await http.post({
        url: '/read/question',
        data
    })
    if (+res.code === 1) {
        let __question_content = res.data.question_content.replace(/(\.|\'|\‘|\，|\:|\))/ig, '$1 ').replace('(', ' (') // eslint-disable-line
        res.data.question_content = __question_content
        return res
    } else {
        return res
    }
}
// 阅读生词
export const fetchReadWord = async (data) => {
    let res = await http.post({
        url: '/read/readword',
        data
    })
    return res
}

// 阅读加入生词本
export const addReadDiffWord = async (data) => {
    let res = await http.post({
        url: '/read/addword',
        data
    })
    return res
}

// 提交答案

export const handUpQuestion = async (data) => {
    let res = await http.post({
        url: '/read/handupquestion',
        data
    })
    return res
}



// 报告
export const readReport = async (data) => {
    let res = await http.post({
        url: '/read/listenreport',
        data
    })
    if (+res.code === 1) {
        let __question_content = res.data.question_content.replace(/(###\d{0,}###)/g, '  $1  ').replace(/(\'|\‘|\，|\:|\))/ig, '$1 ').replace('(', ' (') // eslint-disable-line
        res.data.question_content = __question_content
        return res
    } else {
        return res
    }
}

// 阅读打印
// question_type  阅读1 填空6
export const printData = async (data) => {
    let res = await http.post({
        url: '/word/prints',
        data
    })
    return res
}
